<?php

// Init owncloud

require_once(OC_App::getAppPath('jobposition') . "/lib/position.php");

$LoginStats = PUtil::checkUserLogin(true);
if ($LoginStats !== true) {
   echo $LoginStats;
   exit();
}

OCP\JSON::callCheck();

$jobid = JRequest::getInt('jobid', 0);
$auto = JRequest::getInt('auto', 0) ? 1 : 0;

if(!PCompanyHelper::checkJobManagerPermissions($jobid)) {
   OCP\JSON::error(array('error' => '您无权访问该资源'));
   return false;
}

$model = new PJobpositionModelPosition();

if (!$model->setAutoInvite($jobid, $auto)) {
   OCP\JSON::error(array('error' => $model->getError()));
} else {
   OCP\JSON::success();
}
